<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../../style/css/back/style.css"  rel="stylesheet" type="text/css">
    <script src="../../style/js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
          $(function (){
                //页面打开后,自动向servlet发送请求
              $.get("../../role/roles",function (res){
                 if(res.code==202){
                     window.parent.location.replace("../login.html");
                 }else if(res.code==500){
                     alert("服务器忙,请稍后再试!");
                 }else{
                   var str="";

                    for(i=0;i<res.data.length;i++){
                        str += "<tr align='center'>";
                        str+="<td>"+(i+1)+"</td>";
                        str+="<td>"+res.data[i].name+"</td>";
                        str+="<td>"+res.data[i].roleDesc+"</td>";
                        str+="<td>";
                        for (j=0;j<res.data[i].menuList.length;j++){
                               str+=res.data[i].menuList[j].name+",";
                        }
                        str+="</td>";
                        str+="<td><a href='javaScript:void(0)' onclick='toupdate("+res.data[i].id+")' class='tablelink'>修改</a> " +
                            "     <a href='javaScript:void(0)' onclick='del("+res.data[i].id+")' class='tablelink'>删除</a></td>";
                        str+="</tr>";
                    }
                   $("#tableId").append(str);
                 }
              },"json");
          })

    </script>
</head>
<body>
<div class="rightinfo">
    <!-- 顶部按钮 -->
    <div class="tools">
        <ul class="toolbar">
                <li class="click">
                    <span><img src="../../style/img/back/t01.png" /></span>
                    添加
                </li>
        </ul>
    </div>
    <!--数据列表 -->
    <table class="tablelist" id="tableId">
       <tr>
           <th>序号</th>
           <th>名称</th>
           <th>描述</th>
           <th>菜单</th>
           <th>操作</th>
       </tr>
    </table>
</div>
</body>
</html>